﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ExamSelect : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["studIdcard"] != null)
        {
            if (!Page.IsPostBack)
            {
                bindDTable();
            }
        }
    }
    private void bindDTable()
    {
        DataTable dt = Exam.GetExamDisplayNameByTime();
        gv.DataSource = dt;
        gv.DataBind();
    }

    protected override void Page_LoadOnce()
    {

    }


    protected void goApply_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string emId = gv.DataKeys[e.Row.RowIndex].Values[0].ToString().Trim();
            string emNum = gv.DataKeys[e.Row.RowIndex].Values[2].ToString().Trim();
            string emYear = gv.DataKeys[e.Row.RowIndex].Values[1].ToString().Trim();
            DataTable dt = Exam.getEmTimeByEmId(emId);
            if (dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                HyperLink hlGoApply = (HyperLink)e.Row.FindControl("goApply");
                hlGoApply.NavigateUrl = BSUtility.mainUrl + "BM/BM1.aspx?EmID=" + emId + "&EmYear=" + emYear + "&EmNum=" + emNum;
                DateTime applyBeginTime =DateTime.Parse(dr["ApplyBeginTime"].ToString());
                if (applyBeginTime > DateTime.Now)
                {
                    hlGoApply.Visible = false;
                }
            }
        }
        
    }
}